package cn.forkway;

import cn.forkway.domain.Book;
import cn.forkway.domain.School;
import cn.forkway.domain.Student;
import cn.forkway.domain.Teacher;
import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @program: java-learn-spring
 * @className: testAnn.java
 * @author: River Ray
 * @description: 测试注解注入
 * @createTime 2021年10月13日 20:45:00
 */
public class testAnn {

   public static ApplicationContext  ac;
   @BeforeClass
   public static  void init(){
      String config ="applicationContext.xml";
      ac = new ClassPathXmlApplicationContext(config);

   }

   @Test
   public void simple() {
      Student stu1 = (Student) ac.getBean("stu1");
      System.out.println(stu1);
   }

   @Test
   public void simpleValue() {
      Book book01 = (Book) ac.getBean("book01");
      System.out.println(book01);
   }

   @Test
   public void simpleValueProperties() {
      School school01 = (School) ac.getBean("school01");
      System.out.println(school01);
   }

   @Test
   public  void simpleValueRef() {
      Teacher teacher01 = (Teacher) ac.getBean("teacher01");
      System.out.println(teacher01);
   }
}
